package com.hqj.controller;


import com.hqj.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/eureka/consumer/tc")
public class TestController {
    //启动类那里已经完成bean的控制反转管理
    @Autowired
    private RestTemplate rt;

    @Autowired
    private TestService ts;

    @RequestMapping("/getOne")
    public Map<String,Object> getOne(){
        String url = "http://eureka-client-8001:8001/eureka/client/tc/getOne";//服务提供者的远程地址
        Map<String,Object> map = rt.getForObject(url,HashMap.class);
        return map;
    }

    @RequestMapping("/getOne2")
    public Map<String,Object> getOne2(){
        return ts.getOne();
    }

}
